function TaskReducer (preTask,action) {
    const {type,data} = action
    switch(type) {
        case 'ADD_TASK': {
            return [...preTask,data ]
        }
        case 'DELETE_TASK': {
            return preTask.filter((t) => t.id !== data.id)
        }
        case 'CHANGE_TASK': {
            return preTask.map(item => {
                if (item.id === data.id) {
                    return data.task
                } else {
                    return t
                }
            })
        }
    }
}
export default TaskReducer